<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php echo $this->breadCrumbs(); ?> :: Insert
  </div>
  
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/order.png" alt="" /><?php echo $_['heading_title'];?></h1>
      <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $_['button_insert']; ?></span></a></div>
    </div>
    <div class="content">
      <form action="<?php echo UA('sale/order_basket/insert');?>" method="post" enctype="multipart/form-data" id="form">
        <table class="list">
          <thead>
            <tr>
              <td class="right"><?php echo $_['text_order_id']?></td>
              <td class="left"><?php echo $_['text_customer']?></td>
              <td class="left"><?php echo $_['text_status']?></td>
              <td class="right"><?php echo $_['text_total']?></td>
              <td class="left"><?php echo $_['text_date_added']?></td>
			  <td><?php echo $_['text_payment_method']?></td>
			  <td><?php echo $_['text_shipping_method']?></td>
              <td class="right"><?php echo $_['text_action']?></td>
            </tr>
          </thead>
          <tbody>
            <tr class="filter">
              <td></td>
              <td></td>
              <td>
				  <select name="filter_order_status_id">
					  <option value="*"></option>
					  <?php echo form_select_option($order_statuses, $filter_order_status_id, false, 'order_status_id', 'name');?>
				  </select>
			  </td>
              <td></td>
              <td colspan="3"><input type="text" name="filter_date_start" value="<?php echo $filter_date_start; ?>" size="12" class="date" /> - <input type="text" name="filter_date_end" value="<?php echo $filter_date_end; ?>" size="12" class="date" /></td>
              <td align="right"><a onclick="filter();" class="button"><span><?php echo $_['button_filter'];?></span></a></td>
            </tr>
           </tbody>
           <tbody class="J_tbody_cm">
            <?php if ($orders) { ?>
            <?php foreach ($orders as $order) { ?>
            <tr onmouseover="$(this).addClass('on');" onmouseout="$(this).removeClass('on');"
				data-id="<?php echo $order['order_id'];?>" <?php if ($order['style']) echo 'class="mark_style', $order['style'], '"';?>>
              <td class="right">
              <a class="tipTrigger" href="javascript:;" rel="<?php echo UA('sale/order/product_info'); ?>&order_id=<?php echo $order['order_id']; ?>"><?php echo $order['order_id']; ?></a>
			 
			 <?php if (!empty($order['note'])) {?>
				  <a id="note-<?php echo $order['order_id']; ?>" onclick="showNoteDialog('order', <?php echo $order['order_id'];?>)">
				    <img src="view/image/note.png" />
				  	<span class="none"><?php echo $order['note'];?></span>
				  </a>
				  <?php } else { ?>
				  <a id="note-<?php echo $order['order_id']; ?>" onclick="showNoteDialog('order', <?php echo $order['order_id'];?>)"></a>
			<?php } ?>
			
			  <?php if ($order['invoice_no'] > 0) {?>
			  <br /> <small><?php echo $order['invoice_prefix'].$order['invoice_no']; ?></small>
			  <?php } ?>
              </td>
              <td class="left">
              <a href="mailto:<?php echo $order['email'];?>" title="<?php echo $order['email'];?>"><?php echo $order['customer']; ?></a>
			  <br /><small><?php echo $order['shipping_city']; ?>, <?php echo $order['shipping_country']; ?></small>
              </td>
              <td class="left">
              <a class="tipTrigger" href="javascript:;" rel="<?php echo UA('sale/order/history'); ?>&order_id=<?php echo $order['order_id']; ?>">
			  <?php if($order['status']) { ?>
			  <span class="label" style="background-color:<?php echo $order['status']['color']; ?>;"><?php echo $order['status']['name']?></span>
			  <?php }?>
			  </a>
              </td>
              <td class="right"><?php echo $order['total']; ?></td>
              <td class="left" title="<?php echo $order['date_modified']; ?>"><?php echo $order['date_added']; ?></td>
			  <td><?php echo $order['payment_method']; ?></td>
			  <td><a class="tipTrigger" href="javascript:;" rel="<?php echo UA('sale/order/shipping_history'); ?>&order_id=<?php echo $order['order_id']; ?>">
			  <?php echo $order['shipping_method']; ?>
			  </a>
			  <?php if ($order['shipping_carrier_code']) echo " <b>($order[shipping_carrier_code])</b>";?>
			  </td>
              <td class="right">[<a href="<?php echo UA('sale/order/info')?>&order_id=<?=$order['order_id']?>" target="_blank"><?php echo $_['text_view']?></a>]</td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="18"><?php echo $_['text_no_results']?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>
  </div>
</div>
<div id="contextMenu" class="contextMenu">
<ul>
<li id="note"><?php echo $_['cm_add_note']; ?></li>
<li id="style1"><span class="mark_style1"><?php echo $_['cm_mark_style1']; ?></span></li>
<li id="style2"><span class="mark_style2"><?php echo $_['cm_mark_style2']; ?></span></li>
<li id="style3"><span class="mark_style3"><?php echo $_['cm_mark_style3']; ?></span></li>
<li id="style4"><span class="mark_style4"><?php echo $_['cm_mark_style4']; ?></span></li>
<li id="style5"><span class="mark_style5"><?php echo $_['cm_mark_style5']; ?></span></li>
<li id="remove">Remove Style</li>
</ul>
</div>
<script src="<?php echo ROOT;?>static/javascript/jquery/jquery.contextmenu.min.js"></script>
<script type="text/javascript"><!--
function filter() {
	url = '<?php echo UA('sale/order_basket/insert'); ?>&filter_reset=1';
	
	var filter_order_status_id = $('select[name=\'filter_order_status_id\']').attr('value');
	
	if (filter_order_status_id != '*') {
		url += '&filter_order_status_id=' + encodeURIComponent(filter_order_status_id);
	}	
	
	var filter_date_start = $('input[name=\'filter_date_start\']').attr('value');
	
	if (filter_date_start) {
		url += '&filter_date_start=' + encodeURIComponent(filter_date_start);
	}
	
	var filter_date_end = $('input[name=\'filter_date_end\']').attr('value');
	
	if (filter_date_end) {
		url += '&filter_date_end=' + encodeURIComponent(filter_date_end);
	}
				
	location = url;
}

//--></script>  
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
	$(".tipTrigger").powerFloat({
		eventType: "click",
		targetMode: "ajax"
	});
});
//--></script> 
<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});

$('.J_tbody_cm tr').contextMenu('contextMenu', {
	bindings: {
		'note': function(tr) {showNoteDialog('order', $(tr).attr('data-id'));},
		'style1': function(tr) {
			$(tr).addClass('mark_style1');
			markStyle('order', $(tr).attr('data-id'), 1);
		},
		'style2': function(tr) {
			$(tr).addClass('mark_style2');
			markStyle('order', $(tr).attr('data-id'), 2);
		},
		'style3': function(tr) {
			$(tr).addClass('mark_style3');
			markStyle('order', $(tr).attr('data-id'), 3);
		},
		'style4': function(tr) {
			$(tr).addClass('mark_style4');
			markStyle('order', $(tr).attr('data-id'), 4);
		},
		'style5': function(tr) {
			$(tr).addClass('mark_style5');
			markStyle('order', $(tr).attr('data-id'), 5);
		},
		'remove': function(tr) {
			$(tr).removeClass();
			markStyle('order', $(tr).attr('data-id'), 0);
		}
	}
});
//--></script> 
<?php echo $footer; ?>